window.onload = function() {
	document.getElementsByName("mit")[0].disabled = true;	
	document.getElementsByName("avatar")[0].onchange = validateAll;	
	document.getElementsByName("email")[0].onkeyup = validateAll;
	document.getElementsByName("about")[0].onkeyup = validateAll;	
}

function validateAvatar() {
	var ava = document.getElementsByName("avatar")[0].value;
	var re = /\S+.jpeg|\S+.jpg/i;
	if(!re.test(ava)) return false;
	return true;
}

function validateEmail() {
	var email = document.getElementsByName("email")[0].value;
	var re = /\S+@\S+\.\S+\S+/;
	if(!re.test(email)) return false;
	return true;
}

function validateAll() {
	if(validateAvatar() && validateEmail()) {
		document.getElementsByName("mit")[0].disabled = false;
	} else {
		document.getElementsByName("mit")[0].disabled = true;
	}
}


